package com.jadeen.controller.serverController;


import com.jadeen.common.controller.BaseController;
import com.jadeen.common.domain.AjaxResult;
import com.jadeen.common.page.TableDataInfo;
import com.jadeen.entity.domain.ResourceLink;
import com.jadeen.service.IResourceLinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资源链接Controller
 *
 * @author jadeen
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/share/link")
public class ResourceLinkController extends BaseController {
    @Autowired
    private IResourceLinkService resourceLinkService;

    /**
     * 查询资源链接列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ResourceLink resourceLink) {
        startPage();
        List<ResourceLink> list = resourceLinkService.selectResourceLinkList(resourceLink);
        return getDataTable(list);
    }


    /**
     * 获取资源链接详细信息
     */
    @GetMapping(value = "/{linkId}")
    public AjaxResult getInfo(@PathVariable("linkId") Long linkId) {
        return success(resourceLinkService.selectResourceLinkByLinkId(linkId));
    }

    /**
     * 新增资源链接
     */
    @PostMapping
    public AjaxResult add(@RequestBody ResourceLink resourceLink) {
        return toAjax(resourceLinkService.insertResourceLink(resourceLink));
    }

    /**
     * 修改资源链接
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ResourceLink resourceLink) {
        return toAjax(resourceLinkService.updateResourceLink(resourceLink));
    }

    /**
     * 删除资源链接
     */
    @DeleteMapping("/{linkIds}")
    public AjaxResult remove(@PathVariable Long[] linkIds) {
        return toAjax(resourceLinkService.deleteResourceLinkByLinkIds(linkIds));
    }
}
